{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "db9bdcca",
   "metadata": {},
   "source": [
    "1. 导入NumPy库，并查看当前NumPy 版本号."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "db56518f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ffaaed26",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1.24.3'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "85e862fc",
   "metadata": {},
   "source": [
    "2.使用aranage 函数创建一维数组，输出结果为array([11,22,33,44,55,66,77,88 ,99])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e9ea68c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([11, 22, 33, 44, 55, 66, 77, 88, 99])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(11,100,11)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d737a02",
   "metadata": {},
   "source": [
    "3.使用numpy创建一个3行3列数组元素其值全是False(使用2种方式创建)。注意:只能使用numpy的数组创建函数直接生成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "8ee4eef8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False, False],\n",
       "       [False, False, False],\n",
       "       [False, False, False]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.full((3,3),False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c7f5fd94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False, False],\n",
       "       [False, False, False],\n",
       "       [False, False, False]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros((3,3),dtype=bool)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e63c25d",
   "metadata": {},
   "source": [
    "4.使用numpy生成一个1~200之间的奇数数据,然后将其转换为20行5列的2维数组，数据类型为浮点型。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "883b32b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr1 = np.arange(1,200,2,dtype=float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "c04be002",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  1.,   3.,   5.,   7.,   9.,  11.,  13.,  15.,  17.,  19.,  21.,\n",
       "        23.,  25.,  27.,  29.,  31.,  33.,  35.,  37.,  39.,  41.,  43.,\n",
       "        45.,  47.,  49.,  51.,  53.,  55.,  57.,  59.,  61.,  63.,  65.,\n",
       "        67.,  69.,  71.,  73.,  75.,  77.,  79.,  81.,  83.,  85.,  87.,\n",
       "        89.,  91.,  93.,  95.,  97.,  99., 101., 103., 105., 107., 109.,\n",
       "       111., 113., 115., 117., 119., 121., 123., 125., 127., 129., 131.,\n",
       "       133., 135., 137., 139., 141., 143., 145., 147., 149., 151., 153.,\n",
       "       155., 157., 159., 161., 163., 165., 167., 169., 171., 173., 175.,\n",
       "       177., 179., 181., 183., 185., 187., 189., 191., 193., 195., 197.,\n",
       "       199.])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "7f5d5e0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr1 = arr1.reshape(20,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "58ddd0fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[145.,  57.,  95., 193., 115.],\n",
       "       [ 29.,  13.,  59.,  55.,  89.],\n",
       "       [151., 161., 139.,  17., 159.],\n",
       "       [ 51., 189., 173., 117.,  15.],\n",
       "       [ 45.,  27.,  23., 179.,  81.],\n",
       "       [ 67., 199.,   1., 155., 121.],\n",
       "       [ 65.,  83., 143., 167., 109.],\n",
       "       [ 41.,  25., 107.,   9., 185.],\n",
       "       [141., 147.,  73., 187.,  61.],\n",
       "       [119.,  63., 111.,  33., 113.],\n",
       "       [ 35.,  93., 191.,  43.,   7.],\n",
       "       [ 37.,   3.,  39.,  19., 103.],\n",
       "       [153.,  79., 105.,  11.,  47.],\n",
       "       [163., 133.,  49., 125., 135.],\n",
       "       [ 21.,  87.,  97.,  75.,  69.],\n",
       "       [ 99., 169., 149.,  77., 181.],\n",
       "       [129., 127.,  91., 165., 131.],\n",
       "       [137., 171., 183., 157.,   5.],\n",
       "       [ 53.,  85.,  31., 195.,  71.],\n",
       "       [177., 197., 123., 175., 101.]])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6abda83d",
   "metadata": {},
   "source": [
    "5.依据上题生成的数据，进行就地随机排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "6f0dde04",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.shuffle(arr1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "3d58e109",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 37.,   3.,  39.,  19., 103.],\n",
       "       [151., 161., 139.,  17., 159.],\n",
       "       [ 51., 189., 173., 117.,  15.],\n",
       "       [141., 147.,  73., 187.,  61.],\n",
       "       [ 65.,  83., 143., 167., 109.],\n",
       "       [ 99., 169., 149.,  77., 181.],\n",
       "       [ 45.,  27.,  23., 179.,  81.],\n",
       "       [ 21.,  87.,  97.,  75.,  69.],\n",
       "       [ 41.,  25., 107.,   9., 185.],\n",
       "       [177., 197., 123., 175., 101.],\n",
       "       [ 35.,  93., 191.,  43.,   7.],\n",
       "       [153.,  79., 105.,  11.,  47.],\n",
       "       [129., 127.,  91., 165., 131.],\n",
       "       [ 29.,  13.,  59.,  55.,  89.],\n",
       "       [ 67., 199.,   1., 155., 121.],\n",
       "       [ 53.,  85.,  31., 195.,  71.],\n",
       "       [137., 171., 183., 157.,   5.],\n",
       "       [119.,  63., 111.,  33., 113.],\n",
       "       [145.,  57.,  95., 193., 115.],\n",
       "       [163., 133.,  49., 125., 135.]])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fe5b124",
   "metadata": {},
   "source": [
    "6.创建一个10行4列的正态高斯分布样本值，并进行转置操作(转置用T属性)。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5f4a38e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr2 = np.random.randn(10,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "a6953972",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-3.86554008e-01,  1.61201496e+00, -2.95354117e-01,\n",
       "         9.60121008e-01],\n",
       "       [-4.79647365e-01,  7.75013222e-01, -1.10259453e-01,\n",
       "        -6.13930273e-01],\n",
       "       [ 5.38252121e-01, -8.66060459e-01,  1.37448579e+00,\n",
       "         6.76178523e-01],\n",
       "       [ 7.24591192e-01, -1.19326316e+00,  9.97804272e-01,\n",
       "        -8.98431088e-01],\n",
       "       [-1.87389333e-01, -7.00079667e-01,  8.66472018e-01,\n",
       "        -2.77923641e-02],\n",
       "       [-8.57819537e-01, -5.04197177e-01, -1.55195394e+00,\n",
       "        -3.03667519e+00],\n",
       "       [-1.44934387e+00,  8.65789037e-01,  7.37565705e-01,\n",
       "         9.17857456e-01],\n",
       "       [ 8.90753984e-01,  1.89996371e-01,  1.41429406e+00,\n",
       "        -1.23207930e+00],\n",
       "       [ 2.53302410e+00, -1.09203535e+00,  6.52026972e-01,\n",
       "         3.70891109e-01],\n",
       "       [ 2.97724772e-01,  1.24723561e-03, -9.25531544e-01,\n",
       "        -8.83732338e-02]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "2493a413",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-3.86554008e-01, -4.79647365e-01,  5.38252121e-01,\n",
       "         7.24591192e-01, -1.87389333e-01, -8.57819537e-01,\n",
       "        -1.44934387e+00,  8.90753984e-01,  2.53302410e+00,\n",
       "         2.97724772e-01],\n",
       "       [ 1.61201496e+00,  7.75013222e-01, -8.66060459e-01,\n",
       "        -1.19326316e+00, -7.00079667e-01, -5.04197177e-01,\n",
       "         8.65789037e-01,  1.89996371e-01, -1.09203535e+00,\n",
       "         1.24723561e-03],\n",
       "       [-2.95354117e-01, -1.10259453e-01,  1.37448579e+00,\n",
       "         9.97804272e-01,  8.66472018e-01, -1.55195394e+00,\n",
       "         7.37565705e-01,  1.41429406e+00,  6.52026972e-01,\n",
       "        -9.25531544e-01],\n",
       "       [ 9.60121008e-01, -6.13930273e-01,  6.76178523e-01,\n",
       "        -8.98431088e-01, -2.77923641e-02, -3.03667519e+00,\n",
       "         9.17857456e-01, -1.23207930e+00,  3.70891109e-01,\n",
       "        -8.83732338e-02]])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2.T"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
